<template>
	<view class="">
		<u-navbar title="群聊列表" :fixed="true" :placeholder="true" :safeAreaInsetTop="true" :autoBack="false"
			leftIconColor="#333" titleStyle="color:#333" bgColor="#E0DDDA" @leftClick="leftClick"></u-navbar>
		<view class="new_box flex_dq" v-for="item in list " :key="item.id" @click="gochat(item.hx_group_id)" >
			<view class="notice">
				<image :src="item.avatar" mode=""></image>
				<!-- <text class="notice_txt"></text> -->
			</view>
			<view class=" flex_Z">
				<text class="f36 c3 marb">{{item.name}}</text>
				<text class="f28 c4"></text>
			</view>
		</view>
		<noDatas  :xxxList="list" :showMore="false"></noDatas>
		
	</view>

</template>

<script>
	import WebIM from "../../utils/WebIM.js"
	import {
		memberGroupList
	} from "../../api/hx.js"
	
	export default {
		data() {
			return {
				list:[]
			}
		},
		onShow() {
			this.getlist()
		},
		methods: {
			gochat(id){
				uni.navigateTo({
					url:"/pagesMy/chat/chat?id="+id
				})
			},
			getlist() {
				memberGroupList({}).then(res=>{
					if(res.code==1){
						this.list=res.data
					}
				})
			},
			leftClick() {
				//获取页面栈的长度
				const canNavBack = getCurrentPages()
				console.log(canNavBack.length);
				// 判断是否刷新了浏览器，刷新了浏览器，页面栈只有当前一个
				if (canNavBack.length > 1) {
					uni.navigateBack({
						delta: 1
					})
				} else {
					uni.switchTab({
						url: '/pages/index/index'
					})
				}
			},
		}
	}
</script>

<style scoped lang="scss">
	.new_box {
		width: 100%;
	}

	.notice {
		position: relative;
	}

	.notice>image {
		width: 120rpx;
		height: 120rpx;
		border-radius: 50%;
		margin: 0 22rpx;
	}

	.notice_txt {
		position: absolute;
		top: 4rpx;
		right: 16rpx;
		font-size: 24rpx;
		color: #ffffff;
		background: red;
		padding: 6rpx 16rpx;
		border-radius: 40rpx;
	}
</style>